﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MSPE.Public.FOSS.AutoStatusPlus.TimerJob
{
    class TimesheetHeader
    {
        #region Properties
        /// <summary>
        /// Timesheet Name
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// Resource Name
        /// </summary>
        public string ResName { get; private set; }

        /// <summary>
        /// Timesheet creator resource name
        /// </summary>
        public string CreatorResName { get; private set; }

        /// <summary>
        /// Timesheet creator resource UID 
        /// </summary>
        public Guid CreatorResUid { get; private set; }

        /// <summary>
        /// Resource UID
        /// </summary>
        public Guid ResUid { get; private set; }

        /// <summary>
        /// Period UID
        /// </summary>
        public Guid PeriodUid { get; private set; }

        /// <summary>
        /// Total actual value in hours
        /// </summary>
        public decimal TotalActValue { get; private set; }
        #endregion

        #region Constructor
        /// <summary>
        /// Timesheet header information
        /// </summary>
        /// <param name="timesheetDs">Timesheet DataSet</param>
        public TimesheetHeader(TimesheetSvc.TimesheetDataSet timesheetDs)
        {
            Name            = timesheetDs.Headers[0].TS_NAME;
            ResName         = timesheetDs.Headers[0].TS_CACHED_RES_NAME;
            CreatorResName  = timesheetDs.Headers[0].TS_CACHED_CREATOR_RES_NAME;
            CreatorResUid   = timesheetDs.Headers[0].TS_CREATOR_RES_UID != Guid.Empty ? timesheetDs.Headers[0].TS_CREATOR_RES_UID : Guid.NewGuid();
            ResUid          = timesheetDs.Headers[0].RES_UID != Guid.Empty ? timesheetDs.Headers[0].RES_UID : Guid.NewGuid();
            PeriodUid       = timesheetDs.Headers[0].WPRD_UID != Guid.Empty ? timesheetDs.Headers[0].WPRD_UID : Guid.NewGuid();
            TotalActValue   = timesheetDs.Headers[0].TS_TOTAL_ACT_VALUE/60000;
        }
        #endregion
    }
}
